from datetime import datetime

import requests
import toml


class MessagePush():
    def __init__(self):
        self._cfg = toml.load('../utils/config.toml')
        self._robot_url = self._cfg['DINGROBOT']['robot_url']
        print(self._robot_url)
    def workday_push(self):
        message_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        self._robot_body = {
            "msgtype": "text",
            "text": {
                "content":
                        "每日销售工作提醒-【快普数据更新】\n\n"
                        "1、业务需每日更新快普销售相关工作情况，含快普客商关键要素、场景聚焦、联系记录、商机信息、商机变化。\n\n"
                        "2、主管需每日点评销售联系记录、商机变化。\n\n"
                        "@xxxxxx,@xxxxxx,@xxxxxxxxxxxxx"
            },
            "at": {
                "isAtAll": "false",
                "atMobiles": ["xxxxxxxx","xxxxxxxxx","xxxxx"]
            },
        }
        # logs.info(self._robot_body)
        res = requests.post(url=self._robot_url, json=self._robot_body)
        print(f"钉钉通知状态：{res.json()}")
    def weekend_push(self):
        message_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        self._robot_body = {
            "msgtype": "text",
            "text": {
                "content":
                        "每周销售盘点提醒-【快普业务客户盘点】\n\n"
                        "1、请各业务员和主管在每周日晚完成当周的盘点。\n\n"
                        "@xxxxxx,@xxxxxx,@xxxxxxxxxxxxx"
            },
            "at": {
                "isAtAll": "false",
                "atMobiles": ["xxxxxxxx","xxxxxxxxx","xxxxx"]
            },
        }
        # logs.info(self._robot_body)
        res = requests.post(url=self._robot_url, json=self._robot_body)
        print(f"钉钉通知状态：{res.json()}")

